package com.mapper;

import com.bean.Activity;
import com.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Yuicon on 2017/3/23.
 */
@Repository
public interface UserActivityMapper {

    @Insert("insert into tb_user_activity(id,user_id,activity_id) " +
            "values(#{param1},#{param2},#{param3})")
    int insert(String id, String userId, String activityId);

    @Select("select tb_activity.* from tb_user_activity, tb_activity " +
            " where tb_user_activity.user_id = #{userId} and tb_user_activity.activity_id = tb_activity.id")
    List<Activity> findByUserId(String userId);

    @Select("select tb_user.* from tb_user_activity, tb_user " +
            " where tb_user_activity.activity_id = #{ActivityId} and tb_user_activity.user_id = tb_user.id")
    List<User> findByActivityId(String ActivityId);
}
